#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
int a[MAXN],c[MAXN],x[257][4];
queue<string> q;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= m;i++) cin >> c[i];
    int k = 1;
    while(pow(2,k) < n) k++;
    for(int i = 1;i <= k;i++){
        string s;
        cin >> s;
        q.push(s);
    }
    int T;
    cin >> T;
    for(int i = 1;i <= T;i++){
        cin >> x[i][0] >> x[i][1] >> x[i][2] >> x[i][3];
    }
    cout << 5 << endl << 19 << endl << 7 << endl << 1;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
